package windbell.domain.risk.impl;

import edu.fudan.langlab.domain.common.DateFragment;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Date;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;
import windbell.domain.risk.RiskReport;
import windbell.domain.risk.RiskReportDerived;
import windbell.domain.risk.proxy.RiskReportDerivedProxy;

@Entity
@DiscriminatorValue("RISKREPORTDERIVED_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "riskreportderived")
public class RiskReportDerivedImpl extends BaseModelObject implements RiskReportDerived {
  public RiskReportDerivedImpl() {
    super();
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "year", column = @Column(name = "foundDateFragment_year") ), @AttributeOverride(name = "month", column = @Column(name = "foundDateFragment_month") ), @AttributeOverride(name = "absMonth", column = @Column(name = "foundDateFragment_absMonth") ), @AttributeOverride(name = "week", column = @Column(name = "foundDateFragment_week") ), @AttributeOverride(name = "absWeek", column = @Column(name = "foundDateFragment_absWeek") ), @AttributeOverride(name = "day", column = @Column(name = "foundDateFragment_day") ), @AttributeOverride(name = "absDay", column = @Column(name = "foundDateFragment_absDay") ), @AttributeOverride(name = "hour", column = @Column(name = "foundDateFragment_hour") ), @AttributeOverride(name = "absHour", column = @Column(name = "foundDateFragment_absHour") ), @AttributeOverride(name = "workaround", column = @Column(name = "foundDateFragment_workaround") ) } )
  @AssociationOverrides(value = { } )
  private DateFragment foundDateFragment = edu.fudan.langlab.domain.common.DateFragment.create();
  
  public DateFragment getFoundDateFragment() {
    return this.foundDateFragment;
  }
  
  public RiskReportDerived setFoundDateFragment(final DateFragment foundDateFragment) {
    this.foundDateFragment = foundDateFragment;
    return this;			
    
  }
  
  private Boolean isOverDue;
  
  public Boolean getIsOverDue() {
    return this.isOverDue;
  }
  
  public RiskReportDerived setIsOverDue(final Boolean isOverDue) {
    this.isOverDue = isOverDue;
    return this;			
    
  }
  
  public void updateDerived(final RiskReport report) {
    Date _foundDate = report.getFoundDate();
    this.foundDateFragment.initFrom(_foundDate);
  }
  
  public static RiskReportDerived create(final IObjectFactory objectFactory) {
    windbell.domain.risk.RiskReportDerived riskReportDerived = new windbell.domain.risk.impl.RiskReportDerivedImpl(
    );
    objectFactory.create(riskReportDerived);
    return riskReportDerived;			
    
  }
  
  public static RiskReportDerived createRiskReportDerivedImpl(final IObjectFactory objectFactory, final Procedure1<RiskReportDerived> init) {
    windbell.domain.risk.RiskReportDerived riskReportDerived = new windbell.domain.risk.impl.RiskReportDerivedImpl(
    );
    objectFactory.create(riskReportDerived);
    init.apply(riskReportDerived);
    return riskReportDerived;			
    
  }
  
  public RiskReportDerivedProxy toProxy() {
    windbell.domain.risk.proxy.RiskReportDerivedProxy proxy = new windbell.domain.risk.proxy.RiskReportDerivedProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
